@echo off
chcp 65001 >nul
echo Building ARMv7 version for Android...
echo.

cd backend

echo Checking Go version...
go version
echo.

echo [1/1] Building ARMv7 version (most compatible for Android)...
echo Target: linux/arm with ARMv7 support
echo.

set GOOS=linux
set GOARCH=arm
set GOARM=7
set CGO_ENABLED=0

echo Building with parameters:
echo   GOOS=%GOOS%
echo   GOARCH=%GOARCH%  
echo   GOARM=%GOARM%
echo   CGO_ENABLED=%CGO_ENABLED%
echo.

go build -buildvcs=false -ldflags "-s -w" -tags "osusergo netgo static_build" -o ../homebox-armv7 ./app/api

if %ERRORLEVEL% EQU 0 (
    echo.
    echo ✓ SUCCESS: ARMv7 version built successfully!
    echo.
    cd ..
    echo File details:
    dir homebox-armv7
    echo.
    echo ============================================
    echo ARMv7 Android Build Complete!
    echo ============================================
    echo.
    echo File: homebox-armv7
    echo Architecture: ARM 32-bit (ARMv7-A)
    echo Compatibility: Most Android devices (Android 4.0+)
    echo.
    echo Installation Guide:
    echo 1. Install Termux on your Android device
    echo 2. Transfer homebox-armv7 to your device
    echo 3. Copy to Termux: cp /sdcard/homebox-armv7 ~/
    echo 4. Make executable: chmod +x ~/homebox-armv7  
    echo 5. Run: ./homebox-armv7
    echo.
    echo Optional: Use with config file
    echo   ./homebox-armv7 --config config-android.yml
    echo.
) else (
    echo.
    echo ✗ FAILED: ARMv7 build failed
    echo Please check Go installation and try again
    echo.
    cd ..
)

pause